#pragma once
class CHook : public CGameData
{
public:
	DWORD m_mainThreadID = 0;
	Lock m_MainCallLock;
	MainCall* m_MainCall = 0;
	CRITICAL_SECTION m_criticalSection;
	bool m_scriptThread = false;
	bool m_socketThread = false;
public:
	CHook();
	void install();
	MainCall* GetCall();
	void AddCall(MainCall* call);
};

//////////////////////////////////////////////////////////////////////////
//PeekMessageA
static BOOL
(WINAPI* PeekMessageA_old)(
	_Out_ LPMSG lpMsg,
	_In_opt_ HWND hWnd,
	_In_ UINT wMsgFilterMin,
	_In_ UINT wMsgFilterMax,
	_In_ UINT wRemoveMsg) = PeekMessageA;

static BOOL
(WINAPI PeekMessageA_new)(
	_Out_ LPMSG lpMsg,
	_In_opt_ HWND hWnd,
	_In_ UINT wMsgFilterMin,
	_In_ UINT wMsgFilterMax,
	_In_ UINT wRemoveMsg);

//////////////////////////////////////////////////////////////////////////
//WaitForSingleObject
typedef DWORD(WINAPI* TWaitForSingleObject)(
	_In_ HANDLE hHandle,
	_In_ DWORD dwMilliseconds
	);

static TWaitForSingleObject  WaitForSingleObject_old = ::WaitForSingleObject;
static DWORD WINAPI WaitForSingleObject_new(
	_In_ HANDLE hHandle,
	_In_ DWORD dwMilliseconds
);


//////////////////////////////////////////////////////////////////////////
//RtlExitUserThread
typedef VOID(WINAPI* TRtlExitUserThread)(DWORD code);
static TRtlExitUserThread RtlExitUserThread_old = 0;
static VOID WINAPI RtlExitUserThread_new(DWORD code);